package com.kfm.jdbc.day0405;

import java.util.concurrent.BlockingQueue;

public class Eat extends Thread {

    BlockingQueue<String> queue;

    public Eat(BlockingQueue<String> queue, String name) {
        super(name);
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
            try {
                sleep(1000);
                String s = queue.take(); // 会阻塞
                System.out.println(Thread.currentThread().getName() + "吃了" + s);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
